package com.geezdata.cps.base.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class BaseTask {
    private Logger logger = LoggerFactory.getLogger(getClass());

    public abstract void doExecute(String[] args) throws Exception;

    public void preExecute() {

    }

    public void afterExecute() {

    }

    public void execute(String[] args) {
        preExecute();

        try {
            doExecute(args);
        } catch (Exception e) {
            logger.error("Execute task failed", e);
        }

        afterExecute();
    }
}
